package cn.school.teacher.evaluation.dao;

import cn.school.teacher.evaluation.dto.TeacherEvaluationUserTaskDto;
import cn.school.teacher.evaluation.entity.TeacherEvaluationData;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TeacherEvaluationDataDao  extends BaseMapper<TeacherEvaluationData> {

    /**
     * 获取我的任务数据
     */
    @Select(value = "" +
            "select" +
            "   teut.id as teut_id, teut.user_id as user_id, teut.teut_status,  teutUser.username as teut_username, teut.create_time, teut.modify_time, " + // 用户子任务
            "   teta.id teta_id, teta.teta_name, teta.teta_cover_user_id, tetaUser.username as teta_cover_username, teta.teta_status, teta.teta_user_is_visit   " + // 主任务
            "from  " +
            "   t_teacher_evaluation_user_task teut LEFT JOIN t_teacher_evaluation_task teta on (   " +
            "       teut.teta_id = teta.id  " +
            "   ) left JOIN t_sys_user teutUser on (    " +
            "       teut.user_id = teutUser.id  " +
            "   ) left JOIN t_sys_user tetaUser on (    " +
            "       teta.teta_cover_user_id = tetaUser.id   " +
            "   )   " +
            "${ew.customSqlSegment}")
    Page<TeacherEvaluationUserTaskDto> getList(@Param("ew") QueryWrapper<TeacherEvaluationUserTaskDto> queryWrapper);
}
